<%@page contentType="text/html" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <%@include file="/WEB-INF/ibnms/common/base.jsp" %>

    <script type="text/javascript" src="/resources/ibnms/njs/floatbox.js"></script>
    <script type="text/javascript" src="/js/ibnms/view/view.js"></script>
    <%@include file="/WEB-INF/ibnms/common/jqgrid.jsp" %>
    <%@include file="/WEB-INF/ibnms/common/codemirror.jsp" %>
    <%@include file="/WEB-INF/ibnms/common/contextmenu.jsp" %>
    <script language="Javascript">

        $(function () {
            $('#return-btn').click(function () {
                var viewType = $('#viewType').val();
                if ('BOMC' == viewType) {
                    window.location = ('<s:url action="showBOMCInfo" />?kbpClass=' + $('#kbpClass').val().split(':')[0] + "&bzType=11-50");
                } else {
                    window.location = ('<s:url action="showMonitorInfo" />?kbpClass=' + $('#kbpClass').val().split(':')[0]);
                }
            });
        });
    </script>
    <style type="text/css" rel="stylesheet">
        a.interface-detail:hover {
            text-decoration: underline;
        }

        #fixedDiv {
            position: absolute;
            bottom: 0;
            right: 10px;
            height: 125px;
            z-index: 99999;
        }

    </style>
</head>

<body>
<div class="frame">
<input type="hidden" id="kbpClass" value="<s:property value='kbpClass' escapeHtml='true'/>"/>
<input type="hidden" id="viewType" value="${viewType}"/>
<s:if test="%{viewType=='BOMC'}">
    <%@include file="/WEB-INF/ibnms/display/pages/tabBomcDisplayPage.jsp" %>
</s:if>
<s:else>
    <%@include file="/WEB-INF/ibnms/display/pages/tabDisplayPage.jsp" %>
</s:else>
<ibnms:isPermission operationCode="10-12-16-10" >
<div class="frame-head">
    <div class="frame-title"><span id="hostBaseInfoCllTime">网络基本信息&nbsp;&nbsp;&nbsp;&nbsp;${hostBaseInfoCllTime}</span>
    </div>
    <div class="frame-button minus"></div>
</div>
<div class="frame-content">
<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="0">
<s:if test="total==null ||total.size()<1">
    <tr>
        <td>没有采集!</td>
    </tr>
</s:if>
<s:else>
<s:iterator value="total" status="status" var="tt">
    <%@include file="/WEB-INF/ibnms/display/pages/basicInfoPage.jsp" %>
</s:iterator>
</s:else>
</table>
</div>
</ibnms:isPermission>
<ibnms:isPermission operationCode="10-12-16-11" >
<div class="frame-head">
    <div class="frame-title">CPU和内存信息&nbsp;&nbsp;&nbsp;&nbsp;<span id="cpu_cll_time"></span></div>
    <div class="frame-button minus"></div>
</div>
<div class="frame-content">
    <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td style="margin-top: 0px;vertical-align: top">
                <div class="content" style="padding-top: 0;width: 100%;margin-top: 0px">
                    <iframe align="top" id="ifram_cpu" name="ifram" frameborder="0" scrolling="no"
                            src="<s:url action="loadRouterViewCpu"/>?kbpClass=<s:property value='kbpClass' escapeHtml='true'/>" height="210px"
                            width="100%" onload="Javascript:SetWinHeight(this,1)" noresize></iframe>
                </div>
            </td>
            <td style="margin-top: 0px;vertical-align: top">
                <div class="content" style="padding-top: 0;width: 100%;margin-top: 0px">
                    <iframe align="top" id="ifram_mem" name="ifram" frameborder="0" scrolling="no"
                            src="<s:url action="loadRouterViewMemory"/>?kbpClass=<s:property value='kbpClass' escapeHtml='true'/>" height="210px"
                            width="100%" onload="Javascript:SetWinHeight(this,1)" noresize></iframe>
                </div>
            </td>
        </tr>
    </table>
</div>
</ibnms:isPermission>
<s:iterator value="kpiDatas" var="kpiData">
    <ibnms:isPermission operationCode="#kpiData['KBPCLASS']">
    <%@include file="showMonitor_kpiData.jsp" %>
    </ibnms:isPermission>
</s:iterator>

<ibnms:isPermission operationCode="10-12-16-12">
<div class="frame-head">
    <div class="frame-title">端口详细信息&nbsp;&nbsp;&nbsp;&nbsp;<span id="cll_time"></span></div>
    <div class="frame-button minus"></div>
</div>
<div class="frame-content" style="padding: 5px">
    <table id="gridTable"></table>
    <div id="gridPager"></div>
</div>
</ibnms:isPermission>
</div>

<%@ include file="/WEB-INF/ibnms/display/pages/floatBtn.jsp" %>

</body>

<script type="text/javascript">


$(function () {

    var kpiFormatter = function (val, opt, row) {
        var eventCfgId = row[opt.colModel.name + '_EID'] || '',
                kpiId = row[opt.colModel.name + '_KPI'] || '',
                unitId = row['UNIT_ID'] || '',
                unitName = row['UNIT_NAME'] || '';
        return '<span title="" eventCfgId="' + eventCfgId + '", \n\
color="#color#",\n\
kpiId="' + kpiId + '",\n\
unitId="' + unitId + '", \n\
kpiName="' + opt.colModel.kpiName + '", \n\
unitName="' + unitName + '">' + val + ' ' + (opt.colModel.kpiMeasure || '') + '</span>';

    }

// 配置jqGrid组件
    $("#gridTable").jqGrid({
        url: "<s:url action="loadNetPortInfoJSON"/>",
        datatype: "json",
        mtype: "GET",
        height: "auto",
        autowidth: true,
        colNames: ['实体ID', '实体名称', '描述', '索引', '类型', '物理地址', 'IP', '误码率', 'IF_BER_EID', '丢包率',
            'IF_PLR_EID', '利用率', 'IF_BUR_EID', '流入利用率', 'IF_BUR_I_EID', '流出利用率',
            'IF_BUR_O_EID', '流入速率', '流出速率', '流入错包数', 'IF_NEP_I_EID', '流出错包数', 'IF_NEP_O_EID',
            '流入误码数', 'IF_BER_I_EID', '流出误码数', 'IF_BER_O_EID', '管理状态', '操作状态', '端口状态', 'CLL_TIME',
            'IF_BER_EVENT_CLASS', 'IF_PLR_EVENT_CLASS', 'IF_BUR_EVENT_CLASS', 'IF_BUR_I_EVENT_CLASS', 'IF_BUR_O_EVENT_CLASS',
            'IF_NEP_I_EVENT_CLASS', 'IF_NEP_O_EVENT_CLASS', 'IF_BER_I_EVENT_CLASS', 'IF_BER_O_EVENT_CLASS'],
        colModel: [
            {name: 'UNIT_ID', index: 'UNIT_ID', hidden: true},
            {name: 'UNIT_NAME', index: 'UNIT_NAME', hidden: true},
            {name: 'IF_DESC', align: 'left', width: 200, formatter: function (val, opt, row) {
                return '<a href="#" class="interface-detail" unitId="' + row['UNIT_ID'] + '">' + val + '</a>';
            }},
            {name: 'IF_INDEX', hidden: true, align: 'right'},
            {name: 'IF_TYPE', align: 'center'},
            {name: 'IF_MAC', align: 'center', hidden: true},
            {name: 'IF_IPADDR', align: 'center', formatter: function (v) {
                return (v || '').split(":")[0]
            }},
            {name: 'IF_BER', align: 'right', index: 'IF_BER', hidden: true, kpiName: '端口误码率', kpiMeasure: '%', title: false},
            {name: 'IF_BER_EID', index: 'IF_BER_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_PLR', align: 'right', index: 'IF_PLR', hidden: true, kpiName: '端口丢包率', kpiMeasure: '%', title: false},
            {name: 'IF_PLR_EID', index: 'IF_PLR_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BUR', align: 'right', index: 'IF_BUR', hidden: true, kpiName: 'LAN（半双工）端口利用率', kpiMeasure: '%', title: false},
            {name: 'IF_BUR_EID', index: 'IF_BUR_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BUR_I', index: 'IF_BUR_I', align: 'right', hidden: true, kpiName: '端口流入带宽利用率', kpiMeasure: '%', title: false},
            {name: 'IF_BUR_I_EID', index: 'IF_BUR_I_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BUR_O', index: 'IF_BUR_O', align: 'right', hidden: true, kpiName: '端口流出带宽利用率', kpiMeasure: '%', title: false},
            {name: 'IF_BUR_O_EID', index: 'IF_BUR_O_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BU_I', align: 'right', kpiName: '端口流入带宽速率', kpiMeasure: 'bps', formatter: kpiFormatter},
            {name: 'IF_BU_O', align: 'right', kpiName: '端口流出带宽速率', kpiMeasure: 'bps', formatter: kpiFormatter},
            {name: 'IF_NEP_I', index: 'IF_NEP_I', align: 'right', hidden: true, kpiName: '端口流入错包数', title: false},
            {name: 'IF_NEP_I_EID', index: 'IF_NEP_I_EID', index: 'IF_NEP_I_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_NEP_O', index: 'IF_NEP_O', align: 'right', hidden: true, kpiName: '端口流出错包数', title: false},
            {name: 'IF_NEP_O_EID', index: 'IF_NEP_O_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BER_I', index: 'IF_BER_I', align: 'right', hidden: true, kpiName: '端口流入误码率', kpiMeasure: '%', title: false},
            {name: 'IF_BER_I_EID', index: 'IF_BER_I_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_BER_O', index: 'IF_BER_O', align: 'right', hidden: true, kpiName: '端口流出误码率', kpiMeasure: '%', title: false},
            {name: 'IF_BER_O_EID', index: 'IF_BER_O_EID', align: 'center', hidden: true, hidedlg: true},
            {name: 'IF_ADM_STATUS', align: 'center', hidden: true},
            {name: 'IF_OPR_STATUS', align: 'center', hidden: true},
            {name: 'IF_STATUS', align: 'center'},
            {name: 'CLL_TIME', align: 'center', hidden: true, hidedlg: true},
            {name: 'BER_EVENT', index: 'BER_EVENT', hidden: true, hidedlg: true},
            {name: 'PLR_EVENT', index: 'PLR_EVENT', hidden: true, hidedlg: true},
            {name: 'BUR_EVENT', index: 'BUR_EVENT', hidden: true, hidedlg: true},
            {name: 'BUR_I_EVENT', index: 'BUR_I_EVENT', hidden: true, hidedlg: true},
            {name: 'BUR_O_EVENT', index: 'BUR_O_EVENT', hidden: true, hidedlg: true},
            {name: 'NEP_I_EVENT', index: 'NEP_I_EVENT', hidden: true, hidedlg: true},
            {name: 'NEP_O_EVENT', index: 'NEP_O_EVENT', hidden: true, hidedlg: true},
            {name: 'BER_I_EVENT', index: 'BER_I_EVENT', hidden: true, hidedlg: true},
            {name: 'BER_O_EVENT', index: 'BER_O_EVENT', hidden: true, hidedlg: true}
        ],
        viewrecords: true,
        rowNum: 10,
        rowList: [10, 20, 50],
        jsonReader: {
            root: 'rows',
            page: 'page',
            total: 'total',
            records: 'records',
            repeatitems: false
        },
        pager: "#gridPager",
        sortname: 'IF_BU_I',
        sortorder: 'desc',
        hidegrid: true,
        columnChooser: true,// 调整列
        beforeRequest: function () {
            $("#gridTable").getGridParam("postData").kbpClass = '<s:property value="kbpClass" escapeJavaScript="true"/>';
        },
        loadComplete: function () {
            var ids = jQuery("#gridTable").jqGrid('getDataIDs');
            if (ids != null && ids.length > 0) {
                var row_data = jQuery("#gridTable").jqGrid('getRowData', ids[0]);
                $('#cll_time').html(row_data.CLL_TIME);
            }
            for (var i = 0; i < ids.length; i++) {
                var _row = jQuery("#gridTable").jqGrid('getRowData', ids[i]);
                var unitId = _row.UNIT_ID;
                var unitName = _row.UNIT_NAME;
                var _IF_BER = makeKpiValueColorByEventClass('PM-00-02-001-04', '端口误码率', _row.IF_BER, '%', _row.IF_BER_EID, _row.BER_EVENT, unitId, unitName);
                var _IF_PLR = makeKpiValueColorByEventClass('PM-00-02-001-05', '端口丢包率', _row.IF_PLR, '%', _row.IF_PLR_EID, _row.PLR_EVENT, unitId, unitName);
                var _IF_BUR = makeKpiValueColorByEventClass('PM-00-02-001-01', 'LAN（半双工）端口利用率', _row.IF_BUR, '%', _row.IF_BUR_EID, _row.BUR_EVENT, unitId, unitName);
                var _IF_BUR_I = makeKpiValueColorByEventClass('PM-00-02-001-02', '端口流入带宽利用率', _row.IF_BUR_I, '%', _row.IF_BUR_I_EID, _row.BUR_I_EVENT, unitId, unitName);
                var _IF_BUR_O = makeKpiValueColorByEventClass('PM-00-02-001-03', '端口流出带宽利用率', _row.IF_BUR_O, '%', _row.IF_BUR_O_EID, _row.BUR_O_EVENT, unitId, unitName);
                var _IF_NEP_I = makeKpiValueColorByEventClass('PM-00-02-001-11', '', _row.IF_NEP_I, '', _row.IF_NEP_I_EID, _row.NEP_I_EVENT, unitId, unitName);
                var _IF_NEP_O = makeKpiValueColorByEventClass('PM-00-02-001-12', '', _row.IF_NEP_O, '', _row.IF_NEP_O_EID, _row.NEP_O_EVENT, unitId, unitName);
                var _IF_BER_I = makeKpiValueColorByEventClass('PM-00-02-001-13', '端口流入丢包数', _row.IF_BER_I, '%', _row.IF_BER_I_EID, _row.BER_I_EVENT, unitId, unitName);
                var _IF_BER_O = makeKpiValueColorByEventClass('PM-00-02-001-14', '端口流出丢包数', _row.IF_BER_O, '%', _row.IF_BER_O_EID, _row.BER_O_EVENT, unitId, unitName);

                jQuery("#gridTable").jqGrid('setRowData', ids[i], { IF_BER: _IF_BER, IF_PLR: _IF_PLR, IF_BUR: _IF_BUR,
                    IF_BUR_I: _IF_BUR_I, IF_BUR_O: _IF_BUR_O, IF_NEP_I: _IF_NEP_I, IF_NEP_O: _IF_NEP_O, IF_BER_I: _IF_BER_I, IF_BER_O: _IF_BER_O });
                jQuery("#gridTable").find(".new_image").contextMenu(function () {
                    <%@ include file="/WEB-INF/ibnms/display/pages/ibnmsJSPermCode.jsp" %>
                }, "click");
            }


            function makeKpiValueColorByEventClass(kpiID, kpiName, kpiValue, kpiMeasure, fguid, eventClass, unitId, unitName) {
                var url = "<s:url action='activeAlarmList'
                  namespace='/ibnms/alarm'/>?filter.id=none&showFilter=false&iframeId&filter.unitId=" + unitId;
                var onclick_function = 'window.showModalDialog("' + url + '", "", "dialogWidth=1050px;dialogHeight=600px;status=no")';
                var a_href = "<a onclick='" + onclick_function + "' href='#notExtDiv' style='color:#color#' class='a_nouse'>";
                var str = '';
                if (fguid == 0) {
                    str = a_href + kpiValue + kpiMeasure + "</a><a style='display:none'" +
                            " class='_alarm' href='<s:url action='alarmConfigForm'
                              namespace='/ibnms/config'/>?event.unitId=" + unitId + "&event.unitName="
                            + unitName + "&event.kpiId=" + kpiID + "&event.kpiName=" + kpiName + "'>" +
                            "增加告警配置</a>";
                } else {
                    str = a_href + kpiValue + kpiMeasure + "</a><a style='display:none'" +
                            " class='_alarm' href='<s:url action='alarmConfigForm'
                              namespace='/ibnms/config'/>?event.guid=" + fguid + "&event.unitName=" + unitName + "'>" +
                            "修改告警配置</a>";
                }
                str += "<a class='_hisdata' style='display:none' target='_top'" +
                        " href='<s:url action='showPMHisData'/>?pmDataParam.unitId=" +
                        unitId + "&pmDataParam.kpiId=" + kpiID + "&pmDataParam.kpiName=" + kpiName + "'>查看历史性能</a>";
                str += '&nbsp;<span class="new_image"><img src="<%=application.getContextPath()%>/resources/ibnms/nresources/images/10-10.png"/></span>';
                var str_color = '';
                if (eventClass != '0') {
                    str_color = str.replace('#color#', eventColorDict[eventClass].itemName);
                } else {
                    str_color = str.replace(a_href, "<span title='' style='color:green'>");
                    str_color = str_color.replace("</a>", "</span>");
                }
                return str_color;
            }

            $("#gridTable td span[eventCfgId]").contextMenu(function () {
                var items = [],
                        eventCfgId = $(this).attr("eventCfgId"),
                        kpiId = $(this).attr("kpiId"),
                        kpiName = $(this).attr("kpiName"),
                        unitName = $(this).attr("unitName"),
                        unitId = $(this).attr("unitId");
                var exType = getOs();
// alert('eventCfgId='+eventCfgId+',kpiId='+kpiId+',kpiName='+kpiName+',unitId='+unitId+',unitName='+unitName);
                <ibnms:isPermission operationCode="10-10-10-15">
                if (!eventCfgId) {
                    items.push({
                        text: '增加告警配置',
                        click: function () {

                            var url = '<s:url action='alarmConfigForm'
                                             namespace='/ibnms/config'/>?event.unitId=' + unitId + '&event.kpiId=' + kpiId + '&event.kpiName=' + kpiName + '&event.unitName=' + unitName;
                            if('MSIE'==exType||navigator.userAgent.indexOf("rv:11")>0){
                                url = encodeURI(url);
                            }
                            var guid = window.showModalDialog(url, '_self', 'dialogWidth=1050px;dialogHeight=600px;status=no');
                            if(guid){
                                this.text = "修改告警配置";
                                this.href = "<s:url action="alarmConfigForm" namespace="/ibnms/config"/>?event.guid="+guid;
                            }
                        }
                    });
                } else {
                    items.push({
                        text: '修改告警配置',
                        click: function () {
                            window.showModalDialog(encodeURI('<s:url action='alarmConfigForm'
                                             namespace='/ibnms/config'/>?event.guid=' + eventCfgId), '_self', 'dialogWidth=1050px;dialogHeight=600px;status=no');
                        }
                    });
                }
                </ibnms:isPermission>
                items.push({
                    text: '查看历史性能',
                    click: function () {
                        var url = '<s:url action='showPMHisData'/>?pmDataParam.unitId=' + unitId + '&pmDataParam.kpiId=' + kpiId + '&pmDataParam.kpiName=' + kpiName;
                        if('MSIE'==exType||navigator.userAgent.indexOf("rv:11")>0){
                            url = encodeURI(url);
                        }
                        window.showModalDialog(url, '', "dialogWidth=1050px;dialogHeight=600px;status=no");
                    }
                });
                return items;
            }, "click", '&nbsp;<span title="" class="new_image"><img src="<%=application.getContextPath()%>/resources/ibnms/nresources/images/10-10.png"/></span>');
        }
    });
    <%@ include file="/WEB-INF/ibnms/display/pages/ibnmsPermissionCode.jsp" %>
});


$(".interface-detail").live("click", function () {
    window.open(encodeURI('<s:url
            action='showMonitorInterface'/>?unitId=' + $(this).attr("unitId")), '', "height=670,width=800,top=20,left=200,scrollbars=yes");
});
</script>

</html>